<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div {
      width: 200px;
      height: 200px;
      background-color: pink;
    }

    .nav {
      color: red;
    }

    .box {
      width: 300px;
      height: 300px;
      background-color: skyblue;
      margin: 100px auto;
      padding: 10px;
      border: 1px solid #000;
    }
  </style>
<body>
    <div class="nav">123</div>
    <script>
      // 1. 获取元素
      const div =document.querySelector('div')
      // 2.添加类名  class 是个关键字 我们用 className
      div.className ='box'
    </script>


</body>
</html>